package com.fmjava.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.fmjava.fallback.FallbackException;
import com.fmjava.handler.HandlerException;
import com.fmjava.service.VodService;
import com.fmjava.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/*
 *@ClassName VodController
 *@Description 视频上传控制器
 *@Author 吃麻椒的花酱
 *@Date 2021/8/10 22:13
 *@Version 1.0
 */
@RequestMapping("/service_vod/vod")
@RestController
@Api(tags = "上传章节视频")
public class VodController {
    @Autowired
    VodService vodService;

    @PostMapping("/upload")
    @ApiOperation(value = "上传视频")
    public ResponseResult upload(MultipartFile file)
    {

        String s = vodService.uploadVod(file);
        return ResponseResult.ok().data("vodId",s);

    }


    @GetMapping("/deleteVod/{id}")
    @SentinelResource(value = "deleteTest",blockHandlerClass = {HandlerException.class},blockHandler = "blockHandler",
            fallbackClass = {FallbackException.class},fallback = "fallback")
    @ApiOperation(value = "删除视频")
    public ResponseResult deleteVod(@PathVariable("id") String id){
        vodService.deleteVod(id);
        return ResponseResult.ok();
    }
}
